//
//  ViewController.m
//  Example
//
//  Created by gupengling on 2021/5/12.
//

#import "ViewController.h"
#import <WDAlertTipsView/WDAlertTipsView-Swift.h>
#import <Masonry/Masonry.h>

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    UIButton *button = [UIButton buttonWithType:(UIButtonTypeCustom)];
    [button setBackgroundColor:[UIColor redColor]];
    [button setTitle:@"ActionSheet" forState:(UIControlStateNormal)];
    [button setFrame:CGRectMake(100, 100, 100, 50)];
    [button addTarget:self action:@selector(actionSheetButtonClicked:) forControlEvents:(UIControlEventTouchUpInside)];
    [self.view addSubview:button];
}

- (void)actionSheetButtonClicked:(id)sender {
//    WDAlertTipsController *vc = [[WDAlertTipsController alloc] initWithAlertTitle:nil alertOtherTitle:nil preferredStyle:WDAlertTipsControllerStyleActionSheet];
    WDAlertTipsController *vc = [[WDAlertTipsController alloc]
                                  initWithAlertTitle:@"测试ActionSheet"
                                  alertOtherTitle:@"这是一个actionSheet"
                                  preferredStyle:WDAlertTipsControllerStyleAlert];
//                                  preferredStyle:WDAlertTipsControllerStyleActionSheet];
//    vc.tapClose = NO;

    WDAlertConfig *config = [[WDAlertConfig alloc] init];
    config.cornerRadius = 20;
    config.alertBackgroundColor = [UIColor purpleColor];
    config.alertMaxHeight = 200;
    vc.config = config;

    [vc setHeaderContentView:^UIView * _Nullable{
        UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 400)];
        v.backgroundColor = [UIColor greenColor];

        UILabel *lab = [[UILabel alloc] init];
        lab.text = @"这是头部区域";
        lab.backgroundColor = [UIColor darkGrayColor];
        [v addSubview:lab];
        [lab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.mas_equalTo(v);
            make.top.mas_equalTo(v).offset(10);
            make.bottom.mas_equalTo(v).offset(-10);
            make.height.mas_equalTo(50);
        }];
        return v;
    }];

    [vc setBodyContentView:^UIView * _Nullable{
        UIView *v = [[UIView alloc] init];
        v.backgroundColor = [UIColor brownColor];

        UILabel *lab = [[UILabel alloc] init];
        lab.text = @"这是内容区域萨达大";
        lab.numberOfLines = 0;
        lab.backgroundColor = [UIColor yellowColor];
        [v addSubview:lab];
        [lab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.mas_equalTo(v);
            make.top.mas_equalTo(v.mas_top).offset(10);
            make.bottom.mas_equalTo(v.mas_bottom).offset(-90);
            make.height.mas_equalTo(280);
        }];
        return v;
    }];

    [vc setFooterContentView:^UIView * _Nullable{
        UIView *v = [[UIView alloc] init];
        v.backgroundColor = [UIColor greenColor];

        UIView *xx = [[UIView alloc] init];
        [xx setBackgroundColor:[UIColor redColor]];
        [v addSubview:xx];
        [xx mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.mas_equalTo(v);
            make.top.mas_equalTo(v.mas_top).offset(5);
            make.bottom.mas_equalTo(v.mas_bottom).offset(-5);
            make.height.mas_equalTo(30);
        }];

        return v;
    }];

    WDAlertTipsAction *cancelAction = [[WDAlertTipsAction alloc] initWithTitle:@"取消" style:(WDAlertTipsActionStyleCancel) handler:^(WDAlertTipsAction * _Nullable action) {
        NSLog(@"action = %@", action.title);
    }];
    [vc addAction:cancelAction];

    WDAlertTipsAction *defaultAction = [[WDAlertTipsAction alloc] initWithTitle:@"确定" style:(WDAlertTipsActionStyleDefault) handler:^(WDAlertTipsAction * _Nullable action) {
        NSLog(@"action = %@", action.title);
    }];
    [vc addAction:defaultAction];

    WDAlertTipsAction *destructiveAction = [[WDAlertTipsAction alloc] initWithTitle:@"确定" style:(WDAlertTipsActionStyleDestructive) handler:^(WDAlertTipsAction * _Nullable action) {
        NSLog(@"action = %@", action.title);
    }];
    [vc addAction:destructiveAction];

    [self presentViewController:vc animated:YES completion:^{

    }];
}

@end
